package controller;

import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;

import java.util.Collection;
import java.util.List;

/**
 * Created by Shirly on 2016/8/26.
 */
public class aConroller {
    @Test
    public void whenFilterWithCollections2_thenFiltered() {
        List<String> names = Lists.newArrayList("John", "Jane", "Adam", "Tom");
        Collection<String> result = Collections2.filter(names, Predicates.containsPattern("a"));

        Assert.assertEquals(2, result.size());
     //   Assert. assertThat(result, containsInAnyOrder("Jane", "Adam"));

        result.add("anna");
        Assert.assertEquals(5, names.size());
    }
}
